﻿using BullsAndCows;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestBullsAndCows
{
    
    
    /// <summary>
    ///This is a test class for BullsAndCowsTest and is intended
    ///to contain all BullsAndCowsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class BullsAndCowsTest
    {

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ValidateGuess
        ///</summary>
        [TestMethod()]
        public void ValidateGuessTest1234()
        {
            string guess = "1234";
            bool expected = true;
            bool actual = (new BullsAndCows_Accessor()).ValidateGuess(guess);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ValidateGuessTest12345()
        {
            string guess = "12345";
            bool expected = false;
            bool actual = (new BullsAndCows_Accessor()).ValidateGuess(guess);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ValidateGuessTest1b23()
        {
            string guess = "1b23";
            bool expected = false;
            bool actual = (new BullsAndCows_Accessor()).ValidateGuess(guess);
            Assert.AreEqual(expected, actual);
        }
        [TestMethod()]
        public void ValidateGuessTest2212()
        {
            string guess = "2212";
            bool expected = true;
            bool actual = (new BullsAndCows_Accessor()).ValidateGuess(guess);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void GetCountOfBullsAndCowsTest4Bulls()
        {
            BullsAndCows_Accessor target = new BullsAndCows_Accessor();

            string inputGuess = "1212";
            int[] expected = {4,0};
            target.numbers = new int[] {1,2,1,2};

            int[] actual = target.GetCountOfBullsAndCows(inputGuess);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
        }

        [TestMethod()]
        public void GetCountOfBullsAndCowsTest1Caws()
        {
            BullsAndCows_Accessor target = new BullsAndCows_Accessor();

            string inputGuess = "4111";
            int[] expected = { 0, 1 };
            target.numbers = new int[] { 1, 0, 0, 0 };

            int[] actual = target.GetCountOfBullsAndCows(inputGuess);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
        }

        [TestMethod()]
        public void GetCountOfBullsAndCowsTest2Caws2Bulls()
        {
            BullsAndCows_Accessor target = new BullsAndCows_Accessor();

            string inputGuess = "1299";
            int[] expected = { 2, 2 };
            target.numbers = new int[] { 9, 2, 9, 1 };

            int[] actual = target.GetCountOfBullsAndCows(inputGuess);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
        }

        /// <summary>
        ///A test for NewGame
        ///</summary>
        [TestMethod()]
        [DeploymentItem("BullsAndCows.exe")]
        public void NewGameTest()
        {
            BullsAndCows_Accessor target = new BullsAndCows_Accessor();
            target.NewGame();
            Assert.AreEqual(0,target.helperIndex);
            Assert.AreEqual(0, target.attempts);
        }
    }
}
